package com.atguigu.gulimall.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum BizCodeEnum {
    /**
     * 10000 系统未知异常
     */
    UNKNOWN_EXCEPTION(10000,"系统未知异常"),
    /**
     * 10001 参数格式校验失败
     */
    VALID_EXCEPTION(10001,"参数格式校验失败");

    private int code;

    private String msg;

    public static String getMsgByCode(int code){
        for (BizCodeEnum bizCodeEnum : BizCodeEnum.values()) {
            if(bizCodeEnum.getCode()==code){
                return bizCodeEnum.getMsg();
            }
        }
        return null;
    }
}
